import os
import pandas as pd


def dir_to_csv(root_dir):
    data = []
    for root, dirs, files in os.walk(root_dir):
        level = root.replace(root_dir, '').count(os.sep)
        parent = os.path.basename(root) if level == 1 else ''
        for file in files:
            data.append([parent, file, "file"])
        for dir in dirs:
            data.append([parent, dir, "dir"])
    pd.DataFrame(data, columns=["Parent", "Name", "Type"]).to_csv("mindmap.csv", index=False)


dir_to_csv("D:/pythonProject/pom")
